1 #region Using Statements
3 using System.Collections.Generic;
4 using Microsoft.Xna.Framework;
5 using Microsoft.Xna.Framework.Content;
6 using Microsoft.Xna.Framework.Graphics;
7 using Microsoft.Xna.Framework.Input;
8 using Microsoft.Xna.Framework.Storage;
9 using Microsoft.Xna.Framework.GamerServices;
13 namespace SuperPolarity
16 /// This is the main type for your game
18 public class SuperPolarity : Game
20 public GraphicsDeviceManager graphics;
21 SpriteBatch spriteBatch;
23 public static int OutlierBounds;
31 public SuperPolarity()
34 graphics = new GraphicsDeviceManager(this);
35 graphics.PreferMultiSampling = true;
36 graphics.PreferredBackBufferWidth = 1280;
37 graphics.PreferredBackBufferHeight = 720;
38 graphics.ToggleFullScreen();
40 Content.RootDirectory = "Content";
41 ActorFactory.SetGame(this);
42 ParticleEffectFactory.SetGame(this);
43 ActorManager.SetGame(this);
44 ScreenManager.SetGame(this);
46 EntryScreen = (Screen)new GameScreen(this);
50 /// Allows the game to perform any initialization it needs to before starting to run.
51 /// This is where it can query for any required services and load any non-graphic
52 /// related content. Calling base.Initialize will enumerate through any components
53 /// and initialize them as well.
55 protected override void Initialize()
59 InputController.RegisterEventForKey("fullScreenToggle", Keys.F11);
60 InputController.Bind("fullScreenToggle", HandleFullScreenToggle);
62 EntryScreen.Initialize();
63 ScreenManager.Push(EntryScreen);
68 protected void HandleFullScreenToggle(float value)
70 graphics.ToggleFullScreen();
71 graphics.ApplyChanges();
75 /// LoadContent will be called once per game and is the place to load
76 /// all of your content.
78 protected override void LoadContent()
80 // Create a new SpriteBatch, which can be used to draw textures.
81 spriteBatch = new SpriteBatch(GraphicsDevice);
83 EntryScreen.LoadContent();
85 Player = new Player();
86 DebugFont = Content.Load<SpriteFont>("Fonts\\SegoeUIMono14");
90 /// UnloadContent will be called once per game and is the place to unload
93 protected override void UnloadContent()
95 // TODO: Unload any non ContentManager content here
99 /// Allows the game to run logic such as updating the world,
100 /// checking for collisions, gathering input, and playing audio.
102 /// <param name="gameTime">Provides a snapshot of timing values.</param>
103 protected override void Update(GameTime gameTime)
105 if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
108 ScreenManager.Update(gameTime);
110 base.Update(gameTime);
114 /// This is called when the game should draw itself.
116 /// <param name="gameTime">Provides a snapshot of timing values.</param>
117 protected override void Draw(GameTime gameTime)
119 GraphicsDevice.Clear(Color.White);
123 ScreenManager.Draw(spriteBatch);
125 spriteBatch.DrawString(DebugFont, "Score: " + Player.Score.ToString(), new Vector2(10, 10), Color.LightGray);
126 spriteBatch.DrawString(DebugFont, "Multiplier: " + Player.Multiplier.ToString(), new Vector2(10, 30), Color.LightGray);
127 spriteBatch.DrawString(DebugFont, "Lives: " + Player.Lives.ToString(), new Vector2(10, 50), Color.LightGray);